import request from '@/utils/request'

// 获取宠物列表
export function getPetList() {
  return new Promise((resolve) => {
    // 模拟数据
    const data = {
      code: 200,
      msg: "操作成功",
      data: [
        {
          id: 1,
          name: '小橘',
          type: '猫咪',
          breed: '橘猫',
          gender: '公',
          age: '1年3个月',
          weight: '2.5公斤',
          color: '橘色',
          image: '/static/images/pet/cat.png',
          healthRecords: [
            {
              date: '2024-07-15',
              title: '年度体检',
              description: '各项指标正常，建议定期驱虫'
            },
            {
              date: '2024-06-01',
              title: '疫苗接种',
              description: '完成三联疫苗接种'
            }
          ]
        },
        {
          id: 2,
          name: '豆豆',
          type: '狗狗',
          breed: '金毛',
          gender: '公',
          age: '1岁10个月',
          weight: '1.8公斤',
          color: '金黄色',
          image: '/static/images/pet/dog.png',
          healthRecords: [
            {
              date: '2024-08-01',
              title: '驱虫',
              description: '内外驱虫已完成'
            },
            {
              date: '2024-05-10',
              title: '疫苗接种',
              description: '完成狂犬疫苗接种'
            }
          ]
        }
      ]
    };
    
    setTimeout(() => {
      resolve(data);
    }, 300);
  });
}

// 获取宠物详情
export function getPetDetail(id) {
  return new Promise((resolve) => {
    // 模拟数据
    const petData = [
      {
        id: 1,
        name: '小橘',
        type: '猫咪',
        breed: '橘猫',
        gender: '公',
        age: '1年3个月',
        weight: '2.5公斤',
        color: '橘色',
        image: '/static/images/pet/cat.png',
        healthRecords: [
          {
            date: '2024-07-15',
            title: '年度体检',
            description: '各项指标正常，建议定期驱虫'
          },
          {
            date: '2024-06-01',
            title: '疫苗接种',
            description: '完成三联疫苗接种'
          },
          {
            date: '2024-03-20',
            title: '绝育手术',
            description: '手术顺利，恢复良好'
          }
        ]
      },
      {
        id: 2,
        name: '豆豆',
        type: '狗狗',
        breed: '金毛',
        gender: '公',
        age: '1岁10个月',
        weight: '1.8公斤',
        color: '金黄色',
        image: '/static/images/pet/dog.png',
        healthRecords: [
          {
            date: '2024-08-01',
            title: '驱虫',
            description: '内外驱虫已完成'
          },
          {
            date: '2024-05-10',
            title: '疫苗接种',
            description: '完成狂犬疫苗接种'
          }
        ]
      }
    ];
    
    const pet = petData.find(item => item.id === parseInt(id)) || petData[0];
    const data = {
      code: 200,
      msg: "操作成功",
      data: pet
    };
    
    setTimeout(() => {
      resolve(data);
    }, 300);
  });
}

// 获取服务列表
export function getServiceList() {
  return new Promise((resolve) => {
    // 模拟数据
    const data = {
      code: 200,
      msg: "操作成功",
      data: {
        categories: [
          { id: 0, name: '全部' },
          { id: 1, name: '美容' },
          { id: 2, name: '寄养' },
          { id: 3, name: '医疗' },
          { id: 4, name: '训练' }
        ],
        services: [
          {
            id: 1,
            categoryId: 1,
            name: '上门美容',
            description: '专业宠物美容师上门服务',
            price: 199,
            icon: '/static/images/pet/service-grooming.png',
            path: '/pages/pet/service/grooming'
          },
          {
            id: 2,
            categoryId: 1,
            name: '到店美容',
            description: '专业设备，舒适环境',
            price: 149,
            icon: '/static/images/pet/service-salon.png',
            path: '/pages/pet/service/salon'
          },
          {
            id: 3,
            categoryId: 2,
            name: '宠物寄养',
            description: '安全舒适的寄养环境',
            price: 99,
            icon: '/static/images/pet/service-boarding.png',
            path: '/pages/pet/service/boarding'
          },
          {
            id: 4,
            categoryId: 2,
            name: '宠物托管',
            description: '日间照料，专人看护',
            price: 79,
            icon: '/static/images/pet/service-daycare.png',
            path: '/pages/pet/service/daycare'
          }
        ]
      }
    };
    
    setTimeout(() => {
      resolve(data);
    }, 300);
  });
}